import { ref, computed } from "vue";

export function useToggle(initialValue = false) {
  const state = ref(initialValue);

  const toggle = () => {
    state.value = !state.value;
  };

  return {
    state: computed(() => state.value),
    toggle,
    set: (value: boolean) => (state.value = value),
    reset: () => (state.value = initialValue),
  };
}
